<?php
class jObj{getError()
	protected $errors=array('err'=>array(),'wrn'=>array());
	protected function error($msg){ $this->errors['err'][]=$msg; return false;}
	protected function warning($msg){ $this->errors['wrn'][]=$msg; return false;}
	public function hasErrors(){ return !empty($this->errors['err']);}
	public function getError(){ return $this->errors['err'][ count($this->errors['err'])-1 ]; }
	public function getErrors(){ return $this->errors['err']; }
	public function getWarning(){ return $this->errors['wrn'][ count($this->errors['wrn'])-1 ]; }
	public function getWarnings(){ return $this->errors['wrn']; }


	public function maskID($id,$mask){
	  $mask=explode('|', $mask);
	  $res=false;
	  for ($i=0, $cnt=count($mask); $i<$cnt; $i++ ){
	    switch( $mask[$i] ){
	      case 'country':	$res|=preg_match('~[A-Z]{2}~', $id); break;
	      case 'region': 	$res|=preg_match('~rg\w{32}~', $id); break;
	      case 'city': 		$res|=preg_match('~ct\w{32}~', $id); break;
	      case 'urbanarea':
	      case 'urban': 	$res|=preg_match('~ub\w{32}~', $id); break;
	      case 'network': $res|=preg_match('~nt\w{32}~', $id); break;
	      case 'point': 	$res|=preg_match('~pt\w{32}~', $id); break;
	      
	      case 'token': 	$res|=preg_match('~tn\w{32}~', $id); break;
	      case 'user': 		$res|=preg_match('~ur\w{32}~', $id); break;
	      case 'profile': $res|=preg_match('~pl\w{32}~', $id); break;
			}
   	}
   	return $res;
	}
}
?>